<?php
set_time_limit(0);
error_reporting(E_ERROR|E_PARSE);
header("Content-Type:text/html; charset=utf-8");
require_once('../config.php');
$conn = mysql_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname);

function resizeimg($filename,$width,$height){
list($width_orig, $height_orig) = getimagesize($filename); 
$ratio_orig = $width_orig/$height_orig; 
if ($width/$height > $ratio_orig) { 
$width = $height*$ratio_orig; 
} else { 
$height = $width/$ratio_orig; 
}
$image_p = imagecreatetruecolor($width, $height); 
$image = imagecreatefromjpeg($filename); 
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); 
// Output 
imagejpeg($image_p, $filename, 100); 
}
$width=$_POST["width"];
$height=$_POST["height"];
$id=$_GET["id"];
$sqla="select * from ph_img where proid='".$id."'";
  $resulta=mysqli_query($conn,$sqla);
  while($rowa=mysqli_fetch_array($resulta)){
  $filenam="..".$rowa[imgpath];
  if(is_file($filenam)){
  resizeimg($filenam,$width,$height);
   $allstr.='<a href="'.$filenam.'" target="_blank">'.$filenam.'</a> 执行成功!<br />';
  }
  }
echo $allstr;
?>